package com.deyuanyun.pic.settings.support.validateFunc;

import com.deyuanyun.pic.common.validator.vinterface.ValidateInterface;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.deyuanyun.pic.common.spring.SpringAppliction;
import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.validator.vinterface.ValidateInterface;
import com.deyuanyun.pic.settings.mapper.prvlg.UserMapper;

public class UserNameValidata implements ValidateInterface {

	@Override
	public <T, E, C> boolean apply(T t, E e, C c) {
		String username = null ;
		if(ObjectUtil.isNotNullEmpty(t)){
			UserMapper um = SpringAppliction.getBean(UserMapper.class);
			Map<String,Object> map = new HashMap<String,Object>();
			map.put("username", (String)t.toString().trim());
			username = um.selectUserByUsername(map);
		}
		return StringUtils.isBlank(username);
	}

	@Override
	public String getName() {
		return null;
	}
}
